﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.MODEL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DALFactory;

namespace KPIS.GERP.GBMS.BLL
{
    public class StrategyDataBLL : IStrategyDataBLL
    {
        private static readonly IStrategyDataDAL dal = DataAccess.CreateStrategyDataList();

        public StrategyDataBLL()
        {

        }

        public void Insert(string code, string name, string descr, int type, string year_start, string year_end, string gfmis_code)
        {
            StrategyDataInfo strategyDataInfo = new StrategyDataInfo(-1, code, name, descr, year_start, year_end, SystemInfo._ActiveRecordStatus, "", gfmis_code, new StrategyTypeInfo(type), new UserRecordInfo(1, null));

            int chkError = dal.Insert(strategyDataInfo);

            if (chkError == 0)
            {
                // Error
            }
        }

        public void Update(int seq, string code, string name, string descr, int type, string year_start, string year_end, string gfmis_code)
        {
            StrategyDataInfo strategyDataInfo = new StrategyDataInfo(seq, code, name, descr, year_start, year_end, SystemInfo._ActiveRecordStatus, "", gfmis_code, new StrategyTypeInfo(type), new UserRecordInfo(null, 1));

            int chkError = dal.Update(strategyDataInfo);

            if (chkError == 0)
            {
                // Error
            }
        }

        public void Delete(int seq)
        {
            int chkError = dal.Delete(seq);
        }

        public IList<StrategyDataInfo> Search(int seq)
        {
            return Search(seq, "", "", "", 0);
        }

        public IList<StrategyDataInfo> Search(int seq, string code, string name, string descr, int type)
        {
            StrategyDataInfo strategyDataInfo = new StrategyDataInfo(seq, code, name, descr, "", "", SystemInfo._ActiveRecordStatus, "", "", new StrategyTypeInfo(type), null);

            return dal.Search(strategyDataInfo);
        }
        public bool CheckDuplicateCode(string code, string currentSeq)
        {
            return dal.CheckDuplicateCode(code, currentSeq);
        }
    }
}
